class Solution(object):
    def minMoves2(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        nums.sort()
        n = len(nums)
        mid = n // 2
        count = 0
        for i in range(n):
            count += abs(nums[i] - nums[mid])
        return count



data = Solution()
nums = [1, 2, 3]
print(data.minMoves2(nums))
nums = [1, 1, 2]
print(data.minMoves2(nums))
nums = [1, 0, 0, 8, 6]
print(data.minMoves2(nums))
